import React from 'react';
import { connect } from 'dva';

const buttonStyle = {
  height: 112,
  width: '100%',
  color: 'white',
  fontWeight: 'bold',
  textAlign: 'center',
  border: 'none',
  borderRadius: 2,
};

const Toggle = ({ toggle }) => (
  <div>
    <button
      style={{ ...buttonStyle, backgroundColor: '#e23f46', marginBottom: 16 }}
      onClick={() => toggle(false)}
    >STOP PROGRAM</button>
    <button
      style={{ ...buttonStyle, backgroundColor: '#c5ead2' }}
      onClick={() => toggle(true)}
    >RUN PROGRAM</button>
  </div>
);

export default connect(
  null,
  dispatch => ({
    toggle: run => dispatch({ type: 'app/toggle', payload: run }),
  }),
)(Toggle);
